/*
 * Copyright (C) 2020-present, kinbug All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitee.kinbug.sniper.common.enums;

import java.util.Arrays;

import lombok.Getter;

/**
 * -描述
 * @ClassName: CandlestickIntervalEnum
 * @author kinbug
 * @date 2020-12-2
 */
@Getter
public enum CandleEnum {
	/** 一分钟 */
	MIN1("1min"),
	/** 5分钟 */
	MIN5("5min"),
	/** 15分钟 */
	MIN15("15min"),
	/** 30分钟 */
	MIN30("30min"),
	/** 1小时 */
	HOUR1("60min"),
	/** 4小时 */
	HOUR4("4hour"),
	/** 1天 */
	DAY1("1day"),
	/** 1月 */
	MON1("1mon"),
	/** 1周 */
	WEEK1("1week"),
	/** 1年 */
	YEAR1("1year");

	private final String code;

	CandleEnum(String code) {
		this.code = code;
	}
	
	public static CandleEnum offer(String candleStr) {
		return Arrays.stream(values()).filter(i -> candleStr.contains(i.getCode())).findFirst().orElse(null);
	}
}
